<?php
/* OpenBIBLIO -- A library administration web interface
 * Copyright (C) 2002-2005 Frederic Descamps <lefred@tiscali.be>
 * Copyright (C) 2011-     Laurent Luyssen   <big.lol13@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
session_start();
include_once("includes/functions.inc");
include_once("includes/db.inc");
include_once("includes/session.inc");

if (isset($_POST['login']))
	$login = $_POST['login'];
else 
	$login = true;

if (isset($_POST['pwd']))
	$pwd = $_POST['pwd'];
else
	$pwd = '';

if (isset($_POST['user']))
	$user = $_POST['user'];
else
	$user = '';

ControleAcces("admin.php",$login,$pwd,$user_id,session_id());
if($user_id) {
	$action = false;
	if (isset($_POST['action']))
		$action = $_POST['action'];
	else {
		if (isset($_GET['action']))
			$action = $_GET['action'];
}

$type = false;
if (isset($_POST['type'])) 
	$type = $_POST['type']; 
else {
	if (isset($_GET['type'])) 
		$type = $_GET['type'];
}
if (isset($_GET['menu'])) 
	$type = $_GET['menu'];

$user = GetUserLogin();   
include("includes/header.inc");

if (!$action) {
?>
   <CENTER>
   <TABLE CELLSPACING=7>
   <TR>
	   <th><?php echo _("Ajout"); ?></th>
	   <th><?php echo _("Modification"); ?></th>
	   <th><?php echo _("Effacement"); ?></th>
   </tr>
   <TR>
	   <TD><A HREF="admin.php?action=add&type=admin"><?php echo _("Ajouter un administrateur"); ?></A></TD>
	   <TD><A HREF="admin.php?action=mod&type=admin"><?php echo _("Modifier un administrateur"); ?></A></TD>
	   <TD><A HREF="admin.php?action=del&type=admin"><?php echo _("Effacer un administrateur"); ?></A></TD>
   </tr>
   <TR>
	   <TD><A HREF="admin.php?action=add&type=eleve"><?php echo _("Ajouter un &eacute;l&egrave;ve"); ?></A></TD>
	   <TD><A HREF="admin.php?action=mod&type=eleve"><?php echo _("Modifier un &eacute;l&egrave;ve"); ?></A></TD>
	   <TD><A HREF="admin.php?action=del&type=eleve"><?php echo _("Effacer un &eacute;l&egrave;ve"); ?></A></TD>
   </tr>
   <TR>
	   <TD><A HREF="admin.php?action=add&type=classe"><?php echo _("Ajouter une classe"); ?></A></TD>
	   <TD><A HREF="admin.php?action=mod&type=classe"><?php echo _("Modifier une classe"); ?></A></TD>
	   <td></td>
   </tr>
   <TR>
	   <TD><A HREF="admin.php?action=add&type=livre"><?php echo _("Ajouter un livre"); ?></A></TD>
	   <TD><A HREF="admin.php?action=mod&type=livre"><?php echo _("Modifier un livre"); ?></A></TD>
	   <TD><A HREF="admin.php?action=del&type=livre"><?php echo _("Effacer un livre"); ?></A></TD>
   </tr>
   <TR>
	   <TD><A HREF="admin.php?action=add&type=genre"><?php echo _("Ajouter un genre"); ?></A></TD>
	   <TD><A HREF="admin.php?action=mod&type=genre"><?php echo _("Modifier un genre"); ?></A></TD>
	   <td></td>
   </tr>
   <TR>
	   <TD><A HREF="admin.php?action=add&type=status"><?php echo _("Ajouter un &eacute;tat"); ?></A></TD>
	   <TD><A HREF="admin.php?action=mod&type=status"><?php echo _("Modifier un &eacute;tat"); ?></A></TD>
	   <td></td>
   </tr>   
   <TR>
	   <TD><A HREF="admin.php?action=add&type=location"><?php echo _("Ajouter un emplacement"); ?></A></TD>
	   <TD><A HREF="admin.php?action=mod&type=location"><?php echo _("Modifier un emplacement"); ?></A></TD>
	   <td></td>
   </TR>
   <tr>
	   <TD><A HREF="upload.php"><?php echo _("Import d'un fichier csv"); ?></A></TD>
	   <td></td>
	   <td></td>
   </TR>
   </TABLE>
   <TABLE CELLSPACING=7>
   <TR>
	   <th><?php echo _("Statistiques"); ?></th>
	   <th><?php echo _("Listing"); ?></th>
	   <th><?php echo _("Historique"); ?></th>
   </tr>
   <TR>
	   <TD><A HREF="statsbook.php"><?php echo _("Livres"); ?></A></TD>
	   <TD><A HREF="calendrier.php"><?php echo _("module calendrier"); ?></A></TD>
	   <TD ALIGN=RIGHT><A HREF="histobook.php"><?php echo _("Livres"); ?></A></TD>
   </tr>
   <TR>
	   <TD><A HREF="statsel.php"><?php echo _("El&egrave;ves"); ?></A></TD>
	   <TD><A HREF="classeslist.php"><?php echo _("listing des classes"); ?></A></TD>
	   <TD ALIGN=RIGHT><A HREF="histoel.php"><?php echo _("El&egrave;ves"); ?></A></TD>
   </tr>
   <TR>
	   <TD><A HREF="statclas.php"><?php echo _("Classes"); ?></A></TD>
	   <TD><A HREF="pretlist.php"><?php echo _("emprunts"); ?></A></TD>
	   <td></td>
   </tr>
   <TR>
	   <TD><?php echo _("Graphiques"); ?>&nbsp;<A HREF="graphs.php">1</A>&nbsp;<A HREF="graphs.php?type=2">2</A></TD>
	   <TD><A HREF="retourlist.php"><?php echo _("retours du jour"); ?></A></TD>
	   <td></td>
   </tr>
   </table>
	  
   <TABLE CELLSPACING=7>
   <TR>
	   <th colspan="2"><?php echo _("Configuration"); ?></th>
   </tr>
   <tr>
	   <td width="50%"><a href="admin.php?action=config&type=global"><?php echo _("Configuration globale"); ?></td>
	   <td width="50%"><a href="admin.php?action=config&type=columns"><?php echo _("Colonnes"); ?></a></td>
   </tr>
   </TABLE>
   </CENTER>
   <BR><BR>
   <div>
		<span id=left-text>
			<a href="admin.php?action=logout"><?php echo _("d&eacute;connexion"); ?></a>
			<BR>
			<a href="index.php"><?php echo _("retour menu principal"); ?></a>
		</span> 
		<span id=right-text>   
			<a href="deltemp.php"><?php echo _("effacer les livres temporaires"); ?></a>
		</span>
   </div>
   <br>
   <?php
}

switch($action)
{
    case 'logout':   
		session_destroy();
		echo "<br><br><div id=message>";
		echo _("vous &ecirc;tes d&eacute;connect&eacute;<BR><BR>");
		echo "<A HREF=\"index.php\">";
		echo _("retour menu principal");
		echo "</A>";
		echo "</div>";
		break;

	case 'add':
		switch($type) {
			case 'classe':
				include("classeadd.php");
				break;
			case "admin":
				include("adminadd.php");
				break;
			case "eleve":
				include("eleveadd.php");
				break;
			case "livre":
				include("livreadd.php");
				break;
			case "genre":
				include("genreadd.php");
				break;
			case "status":
				include("etatadd.php");
				break;
			case "location":
				include("locationadd.php");
				break;
		}
		break;
    
    case 'mod':
		switch($type) {
			case "classe":
				include("classemod.php");
				break;
			case "admin":
				include("adminmod.php");
				break;
			case "eleve":
				include("elevemod.php");
				break;
			case "livre":
				include("livremod.php");
				break;
			case "genre":
				include("genremod.php");
				break;
			case "status":                 
				include("etatmod.php");
				break;
			case "location":
				include("locationmod.php");
				break;
		}
		break;
	
    case 'del':
		switch($type) {
			case "admin":
				include("admindel.php");
				break;
			case "eleve":
				include("elevedel.php");
				break;
			case "livre":
				include("livredel.php");
				break;
		}
		break;
	
    case 'config':
		switch($type) {
			case 'global':
				include("config.php");
				break;
			case "columns":
				include "colmod.php";
				break;
		}
		break;
 }
}
include_once("includes/footer.inc");
?>
